package com.sky.controller.admin;

import com.sky.dto.OrdersCancelDTO;
import com.sky.dto.OrdersConfirmDTO;
import com.sky.dto.OrdersPageQueryDTO;
import com.sky.pojo.Courier;
import com.sky.result.PageResult;
import com.sky.result.Result;
import com.sky.service.user.OrderService;
import com.sky.vo.OrderStatisticsVO;
import com.sky.vo.OrderVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController("adminOrderController")
@Api(tags = "商家订单管理接口")
@RequestMapping("/admin/order")
public class OrderController {

    @Autowired
    private OrderService orderService;

    @ApiOperation("商家订单条件查询")
    @GetMapping("/conditionSearch")
    public Result<PageResult> conditionSearch(OrdersPageQueryDTO dto){

        return orderService.conditionSearch(dto);
    }


    @ApiOperation("统计商家各个状态的订单数量")
    @GetMapping("/statistics")
    public Result<OrderStatisticsVO> statistics(){
        return orderService.statistics();
    }


    @ApiOperation("查询订单的详细信息")
    @GetMapping("/details/{orderId}")
    public Result<OrderVO> adminOrderDetails(@PathVariable("orderId") Long orderId){
        return orderService.adminOrderDetails(orderId);
    }


    @ApiOperation("取消订单")
    @PutMapping("/cancel")
    public Result<String> cancel(@RequestBody OrdersCancelDTO dto){
        return orderService.adminCancelOrder(dto);
    }


    @ApiOperation("商家接单")
    @PutMapping("/confirm")
    public Result<Courier> confirm(@RequestBody OrdersConfirmDTO dto){

        return orderService.confirm(dto);
    }


}
